/**
 * Generic Activity.
 *
 * Released under Apache License, Version 2.0.
 */

package bsp.android;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;

public class GenericActivity extends Activity
{
	protected static final int MENU_QUIT = Menu.FIRST;
	
	protected DisplayMetrics mDisplayMetrics;
	protected float mDisplayCenterX, mDisplayCenterY;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		mDisplayMetrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
		mDisplayCenterX = mDisplayMetrics.widthPixels * 0.5f;
		mDisplayCenterY = mDisplayMetrics.heightPixels * 0.5f;
	}
	
	@Override 
	public boolean onCreateOptionsMenu(Menu menu)
	{
		menu.add(0, MENU_QUIT, 0, "Quit").setIcon(android.R.drawable.ic_menu_close_clear_cancel);
		
		return super.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{
		switch (item.getItemId()) {
		case MENU_QUIT:
			finish();
		}
		
		return super.onOptionsItemSelected(item);
	}
}

/* end */
